﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

using Microsoft.Xna.Framework;

namespace CorporationWars
{
    public enum SalaryLevels : int
    {
        MinWage = 12000,
        Junior = 20000,
        Regular = 35000,
        Senior = 55000,
        Principle = 75000,
        LowerMgt = 85000,
        MiddleMgt = 100000,
        SMT = 250000,
    }

    [Serializable]
    public class Staff
    {
        public PersonsName Name { get; set; }
        public decimal Salary { get; set; }
        public string WorkingNode { get; set; }
        public SalaryLevels SalaryBand { get; set; }
        public float Compitance { get; set; }

        Random rnd = new Random(DateTime.Now.Millisecond);

        public Staff(string node, SalaryLevels salaryLevel)
        {
            WorkingNode = node;
            PersonGender gender = PersonGender.Other;
            PersonTitle title = PersonTitle.None;
            int mns = rnd.Next(4);

            #region Gender and Title Creation
            switch (rnd.Next(100))
            {
                case 0:
                    gender = PersonGender.Other;
                    break;
                default:
                    switch (rnd.Next(2))
                    {
                        case 0:
                            gender = PersonGender.Male;
                            switch (rnd.Next(100))
                            {
                                case 0:
                                    title = PersonTitle.Mr;
                                    break;
                                case 1:
                                    title = PersonTitle.Dr;
                                    break;
                                case 2:
                                    title = PersonTitle.Prof;
                                    break;
                                case 3:
                                    title = PersonTitle.Sir;
                                    break;
                                default:
                                    title = PersonTitle.Mr;
                                    break;
                            }
                            break;
                        case 1:
                            gender = PersonGender.Female;
                            switch (rnd.Next(100))
                            {
                                case 0:
                                    title = PersonTitle.Dr;
                                    break;
                                case 1:
                                    title = PersonTitle.Prof;
                                    break;
                                case 2:
                                    title = PersonTitle.Dame;
                                    break;
                                default:
                                    switch (rnd.Next(3))
                                    {
                                        case 0:
                                            title = PersonTitle.Ms;
                                            break;
                                        case 1:
                                            title = PersonTitle.Mrs;
                                            break;
                                        case 2:
                                            title = PersonTitle.Miss;
                                            break;
                                    }
                                    break;
                            }
                            break;
                    }
                    break;
            }
            #endregion

            Name = NameFactory.CreatePersonsName(gender, title, mns);

            SalaryBand = salaryLevel;

            float compStart = 0;
            float compEnd = 1;
            switch (SalaryBand)
            {
                case SalaryLevels.MinWage:
                case SalaryLevels.Junior:
                    Salary = (decimal)MathHelper.Lerp((int)SalaryLevels.MinWage, (int)SalaryLevels.Junior, (float)rnd.NextDouble());
                    compStart = 0;
                    compEnd = .25f;
                    break;
                case SalaryLevels.Regular:
                    Salary = (decimal)MathHelper.Lerp((int)SalaryLevels.Junior, (int)SalaryLevels.Regular, (float)rnd.NextDouble());
                    compStart = .2f;
                    compEnd = .5f;
                    break;
                case SalaryLevels.Senior:
                    Salary = (decimal)MathHelper.Lerp((int)SalaryLevels.Regular, (int)SalaryLevels.Senior, (float)rnd.NextDouble());
                    compStart = .3f;
                    compEnd = .7f;
                    break;
                case SalaryLevels.Principle:
                    Salary = (decimal)MathHelper.Lerp((int)SalaryLevels.Senior, (int)SalaryLevels.Principle, (float)rnd.NextDouble());
                    compStart = .5f;
                    compEnd = .8f;
                    break;
                case SalaryLevels.LowerMgt:
                    Salary = (decimal)MathHelper.Lerp((int)SalaryLevels.Principle, (int)SalaryLevels.LowerMgt, (float)rnd.NextDouble());
                    compStart = 0;
                    compEnd = .25f;
                    break;
                case SalaryLevels.MiddleMgt:
                    Salary = (decimal)MathHelper.Lerp((int)SalaryLevels.LowerMgt, (int)SalaryLevels.MiddleMgt, (float)rnd.NextDouble());
                    compStart = .2f;
                    compEnd = .5f;
                    break;
                case SalaryLevels.SMT:
                    Salary = (decimal)MathHelper.Lerp((int)SalaryLevels.MiddleMgt, (int)SalaryLevels.SMT, (float)rnd.NextDouble());
                    compStart = .5f;
                    compEnd = 1;
                    break;
            }

            Compitance = MathHelper.Lerp(compStart, compEnd, (float)rnd.NextDouble());
        }        
    }
}
